Technotes
T E C H N O T E : A Technique for Figuring Out a Resource's Base Value
In the chapter on the Resource Manager in Inside Macintosh: More Macintosh Toolbox, owned resources are explained, but the chapter does not include a sample of how to actually figure out the resource's base value. This Technnote includes a shortcut in C, Pascal and ASM to accomplish this task.
This Technote is specifically aimed at those developers who need to know
about a resource's ownership, such as developers working on Desk
Accessories or Control Panels.
A Shortcut for Figuring Out a Resource's Base ValueThe functionGetResBase takes the driver number and returns
the ID of the first resource owned by that driver.
This is according to the private resource numbering convention
documented in the Resource Manager chapter on page 1-48 of
Inside Macintosh: More Macintosh Toolbox.
In C, you can use this macro:
#define GetResBase(id) (0xC000 | (((-(id)) - 1) << 5))and in Pascal, you can use this function:
function GetResBase(resID: integer):integer; begin GetResBase := BOR($C000, BSL(longint(((-resID)-1)),5)); end;and for those who still program in 68k asm, you can use this function:
;FUNCTION GetResBase(driverNumber: INTEGER): INTEGER; Further Reference
Change HistoryThis Note was originally written in May, 1986. Since then, it has been rewritten to include Pascal and C versions of the shortcut.Technotes Previous Technote | Contents | Next Technote |